<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org"
	xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>

<body class="gray-bg">
        <div class="col-sm-12 col-sm-offset-0">
            <div class="wrapper wrapper-content animated fadeInUp">
                <div class="ibox">
                    <div class="ibox-content">  
                        <div class="row">
                            <div class="col-sm-12">
                                <div class="m-b-md">
                                    <a href="#" class="btn btn-white btn-xs pull-right">编辑项目</a>
                                    <h2>材料汇总</h2>
                                </div>
                            </div>
                        </div>
                        <dl class="dl-horizontal">
                                    <dt>状态：</dt>
                                    <dd>
                                    	<span id="role" class="label label-primary"></span>
                                    </dd>
                        </dl>
                        <div class="row">
                            <div class="col-sm-5">
                                <dl class="dl-horizontal" th:object="${user}">
                                    <dt>&nbsp;</dt><dd>&nbsp;</dd>
                                    <dt>姓名：</dt>
                                    <dd th:text="*{userName}">获取失败</dd>
                                    <dt>&nbsp;</dt><dd>&nbsp;</dd>
                                    <dt>年龄：</dt>
                                    <dd th:text="*{age}">获取失败</dd>
                                    <dt>&nbsp;</dt><dd>&nbsp;</dd>
                                    <dt>性别：</dt>
                                    <dd th:switch="*{sex}">
                                    	<span th:case="0">男</span>
                                    	<span th:case="1">女</span>
                                    	<span th:case="2">未知</span>
                                    </dd>

                                </dl>
                            </div>
                            <div class="col-sm-7" id="cluster_info" th:object="${user}">
                                <dl class="dl-horizontal">
                                	<dt>&nbsp;</dt><dd>&nbsp;</dd>
                                    <dt>身份证号码：</dt>
                                    <dd th:text="*{idCardNo}">获取失败</dd>
                                    <dt>&nbsp;</dt><dd>&nbsp;</dd>
                                    <dt>邮箱：</dt>
                                    <dd th:text="*{email}">获取失败</dd>
                                    <dt>&nbsp;</dt><dd>&nbsp;</dd>
                                    <dt>电话号码：</dt>
                                    <dd th:text="*{phonenumber}">获取失败</dd>

                                </dl>
                            </div>
                        </div>
                        <div class="row">&nbsp;</div>
                        <div class="row">注：未提交状态时下载的为材料模板</div>
                        <div class="row">
				            <div class="col-sm-3">
				                <div class="ibox">
				                    <div class="ibox-content">
				                        <h3>积极分子培养阶段</h3>
				                        <ul class="sortable-list connectList agile-list" th:object="${user.proposer}">
				                            <li class="danger-element" style="color:red">
				                      		    <a th:href="@{/module/proposer/review(userId=${user.userId},type=partyApplication,fileName=*{partyApplication})}" class="btn btn-warning btn-xs" th:text="入党申请书"></a>
                                    			<a th:href="@{/module/proposer/download(userId=${user.userId},type=partyApplication,fileName=*{partyApplication})}" class="btn btn-success btn-xs" th:text="下载"></a>
				                      			<span th:if="*{partyApplication == null}" class="badge badge-danger ">未提交</span>
				                      			<span th:if="*{partyApplication != null}" class="badge badge-primary ">已提交</span>
				                      			<input th:if="*{partyApplication == null}" style="margin-top: 3px;" class="btn btn-default" value="点击上传文件" onclick="upload(1)">
				                            </li>
				                            
											
											                          
				                        </ul>
				                    </div>
				                </div>
				            </div>
				            
				            <div class="col-sm-3">
				                <div class="ibox">
				                    <div class="ibox-content">
				                        <h3>发展对象培养阶段</h3>
				                        <ul class="sortable-list connectList agile-list" th:object="${user.proposer}">
				                        
				                        	<li class="danger-element" style="color:red">
				                      		    <a th:href="@{/module/proposer/review(userId=${user.userId},type=reportFirst,fileName=*{reportFirst})}" class="btn btn-warning btn-xs" th:text="思想汇报一"></a>
                                    			<a th:href="@{/module/proposer/download(userId=${user.userId},type=reportFirst,fileName=*{reportFirst})}" class="btn btn-success btn-xs" th:text="下载"></a>
				                      			<span th:if="*{reportFirst == null}" class="badge badge-danger ">未提交</span>
				                      			<span th:if="*{reportFirst != null}" class="badge badge-primary ">已提交</span>
				                      			<input th:if="*{reportFirst == null}" style="margin-top: 3px;" class="btn btn-default" value="点击上传文件" onclick="upload(2)">
				                            </li>
				                            
				                            <li class="danger-element" style="color:red">
				                      		    <a th:href="@{/module/proposer/review(userId=${user.userId},type=reportSecond,fileName=*{reportSecond})}" class="btn btn-warning btn-xs" th:text="思想汇报二"></a>
                                    			<a th:href="@{/module/proposer/download(userId=${user.userId},type=reportSecond,fileName=*{reportSecond})}" class="btn btn-success btn-xs" th:text="下载"></a>
				                      			<span th:if="*{reportSecond == null}" class="badge badge-danger ">未提交</span>
				                      			<span th:if="*{reportSecond != null}" class="badge badge-primary ">已提交</span>
				                      			<input th:if="*{reportSecond == null}" style="margin-top: 3px;" class="btn btn-default" value="点击上传文件" onclick="upload(3)">
				                            </li>
				                            
				                            <li class="danger-element" style="color:red">
				                      		    <a th:href="@{/module/proposer/review(userId=${user.userId},type=reportThird,fileName=*{reportThird})}" class="btn btn-warning btn-xs" th:text="思想汇报三"></a>
                                    			<a th:href="@{/module/proposer/download(userId=${user.userId},type=reportThird,fileName=*{reportThird})}" class="btn btn-success btn-xs" th:text="下载"></a>
				                      			<span th:if="*{reportThird == null}" class="badge badge-danger ">未提交</span>
				                      			<span th:if="*{reportThird != null}" class="badge badge-primary ">已提交</span>
				                      			<input th:if="*{reportThird == null}" style="margin-top: 3px;" class="btn btn-default" value="点击上传文件" onclick="upload(4)">
				                            </li>
				                            
				                            <li class="danger-element" style="color:red">
				                      		    <a th:href="@{/module/proposer/review(userId=${user.userId},type=reportFourth,fileName=*{reportFourth})}" class="btn btn-warning btn-xs" th:text="思想汇报四"></a>
                                    			<a th:href="@{/module/proposer/download(userId=${user.userId},type=reportFourth,fileName=*{reportFourth})}" class="btn btn-success btn-xs" th:text="下载"></a>
				                      			<span th:if="*{reportFourth == null}" class="badge badge-danger ">未提交</span>
				                      			<span th:if="*{reportFourth != null}" class="badge badge-primary ">已提交</span>
				                      			<input th:if="*{reportFourth == null}" style="margin-top: 3px;" class="btn btn-default" value="点击上传文件" onclick="upload(5)">
				                            </li>
				                            
				                            
				                            							                            
				                        </ul>
				                    </div>
				                </div>
				            </div>
				            
				            <div class="col-sm-3">
				                <div class="ibox">
				                    <div class="ibox-content">
				                        <h3>预备党员培养阶段</h3>
				                        <ul class="sortable-list connectList agile-list" th:object="${user.proposer}">
				                            
				                            <li class="danger-element" style="color:red">
				                      		    <a th:href="@{/module/proposer/review(userId=${user.userId},type=memoir,fileName=*{memoir})}" class="btn btn-warning btn-xs" th:text="自传"></a>
                                    			<a th:href="@{/module/proposer/download(userId=${user.userId},type=memoir,fileName=*{memoir})}" class="btn btn-success btn-xs" th:text="下载"></a>
				                      			<span th:if="*{memoir == null}" class="badge badge-danger ">未提交</span>
				                      			<span th:if="*{memoir != null}" class="badge badge-primary ">已提交</span>
				                      			<input th:if="*{memoir == null}" style="margin-top: 3px;" class="btn btn-default" value="点击上传文件" onclick="upload(6)">
				                            </li>
											
				                        </ul>
				                    </div>
				                </div>
				            </div>
				            
				            <div class="col-sm-3">
				                <div class="ibox">
				                    <div class="ibox-content">
				                        <h3>正式党员培养阶段</h3>
				                        <ul class="sortable-list connectList agile-list" th:object="${user.proposer}">
				                        
				                            <li class="danger-element" style="color:red">
				                      		    <a th:href="@{/module/proposer/review(userId=${user.userId},type=partyApplicaiton,fileName=*{partyApplicaiton})}" class="btn btn-warning btn-xs" th:text="入党志愿书"></a>
                                    			<a th:href="@{/module/proposer/download(userId=${user.userId},type=partyApplicaiton,fileName=*{partyApplicaiton})}" class="btn btn-success btn-xs" th:text="下载"></a>
				                      			<span th:if="*{partyApplicaiton == null}" class="badge badge-danger ">未提交</span>
				                      			<span th:if="*{partyApplicaiton != null}" class="badge badge-primary ">已提交</span>
				                      			<input th:if="*{partyApplicaiton == null}" style="margin-top: 3px;" class="btn btn-default" value="点击上传文件" onclick="upload(7)">
				                            </li>
				                            
				                            <li class="danger-element" style="color:red">
				                      		    <a th:href="@{/module/proposer/review(userId=${user.userId},type=reportFifth,fileName=*{reportFifth})}" class="btn btn-warning btn-xs" th:text="思想汇报五"></a>
                                    			<a th:href="@{/module/proposer/download(userId=${user.userId},type=reportFifth,fileName=*{reportFifth})}" class="btn btn-success btn-xs" th:text="下载"></a>
				                      			<span th:if="*{reportFifth == null}" class="badge badge-danger ">未提交</span>
				                      			<span th:if="*{reportFifth != null}" class="badge badge-primary ">已提交</span>
				                      			<input th:if="*{reportFifth == null}" style="margin-top: 3px;" class="btn btn-default" value="点击上传文件" onclick="upload(8)">
				                            </li>
				                            
				                            <li class="danger-element" style="color:red">
				                      		    <a th:href="@{/module/proposer/review(userId=${user.userId},type=reportSixth,fileName=*{reportSixth})}" class="btn btn-warning btn-xs" th:text="思想汇报六"></a>
                                    			<a th:href="@{/module/proposer/download(userId=${user.userId},type=reportSixth,fileName=*{reportSixth})}" class="btn btn-success btn-xs" th:text="下载"></a>
				                      			<span th:if="*{reportSixth == null}" class="badge badge-danger ">未提交</span>
				                      			<span th:if="*{reportSixth != null}" class="badge badge-primary ">已提交</span>
				                      			<input th:if="*{reportSixth == null}" style="margin-top: 3px;" class="btn btn-default" value="点击上传文件" onclick="upload(9)">
				                            </li>
				                            
				                            <li class="danger-element" style="color:red">
				                      		    <a th:href="@{/module/proposer/review(userId=${user.userId},type=reportSeventh,fileName=*{reportSeventh})}" class="btn btn-warning btn-xs" th:text="思想汇报七"></a>
                                    			<a th:href="@{/module/proposer/download(userId=${user.userId},type=reportSeventh,fileName=*{reportSeventh})}" class="btn btn-success btn-xs" th:text="下载"></a>
				                      			<span th:if="*{reportSeventh == null}" class="badge badge-danger ">未提交</span>
				                      			<span th:if="*{reportSeventh != null}" class="badge badge-primary ">已提交</span>
				                      			<input th:if="*{reportSeventh == null}" style="margin-top: 3px;" class="btn btn-default" value="点击上传文件" onclick="upload(10)">
				                            </li>
				                            
				                            <li class="danger-element" style="color:red">
				                      		    <a th:href="@{/module/proposer/review(userId=${user.userId},type=reportEighth,fileName=*{reportEighth})}" class="btn btn-warning btn-xs" th:text="思想汇报八"></a>
                                    			<a th:href="@{/module/proposer/download(userId=${user.userId},type=reportEighth,fileName=*{reportEighth})}" class="btn btn-success btn-xs" th:text="下载"></a>
				                      			<span th:if="*{reportEighth == null}" class="badge badge-danger ">未提交</span>
				                      			<span th:if="*{reportEighth != null}" class="badge badge-primary ">已提交</span>
				                      			<input th:if="*{reportEighth == null}" style="margin-top: 3px;" class="btn btn-default" value="点击上传文件" onclick="upload(11)">
				                            </li>
				                            
				                            <li class="danger-element" style="color:red">
				                      		    <a th:href="@{/module/proposer/review(userId=${user.userId},type=officialApplication,fileName=*{officialApplication})}" class="btn btn-warning btn-xs" th:text="转正申请书"></a>
                                    			<a th:href="@{/module/proposer/download(userId=${user.userId},type=officialApplication,fileName=*{officialApplication})}" class="btn btn-success btn-xs" th:text="下载"></a>
				                      			<span th:if="*{officialApplication == null}" class="badge badge-danger ">未提交</span>
				                      			<span th:if="*{officialApplication != null}" class="badge badge-primary ">已提交</span>
				                      			<input th:if="*{officialApplication == null}" style="margin-top: 3px;" class="btn btn-default" value="点击上传文件" onclick="upload(12)">
				                            </li>
											
				                        </ul>
				                    </div>
				                </div>
				            </div>
				           
				            
				        </div>
				                        
                        
                        <div class="row text-center">
                        	<a type="button" href="javascript:" onclick="self.location=document.referrer;" class="btn btn-default btn-lg"><i class="fa fa-check"></i>&nbsp;返 回</a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    
    <div th:include="include :: footer"></div>
    
    <!-- 甜甜的弹出层 -->
 	<script src="https://cdn.bootcss.com/limonte-sweetalert2/7.21.1/sweetalert2.all.js"></script>
    <script th:inline="javascript">
        $(document).ready(function () {
			//填充角色
			var roleId = [[${user.roleIds}]];
			var roleName;
			switch(roleId[0]){
				case 2:
					roleName = "申请人";
					break;
				case 3:
					roleName = "积极分子";
					break;
				case 4:
					roleName = "发展对象";
					break;
				case 5:
					roleName = "预备党员";
					break;
				case 6:
					roleName = "正式党员";
					break;
			}
			$("#role").html(roleName);
			
            $('#loading-example-btn').click(function () {
                btn = $(this);
                simpleLoad(btn, true)

                // Ajax example
                //                $.ajax().always(function () {
                //                    simpleLoad($(this), false)
                //                });

                simpleLoad(btn, false)
            });
        });

        function simpleLoad(btn, state) {
            if (state) {
                btn.children().addClass('fa-spin');
                btn.contents().last().replaceWith(" Loading");
            } else {
                setTimeout(function () {
                    btn.children().removeClass('fa-spin');
                    btn.contents().last().replaceWith(" Refresh");
                }, 2000);
            }
        }
    </script>
    
    <script th:inline="javascript">
        var userId= [[${user.userId}]];
        var partyApplication = [[${user.proposer.partyApplication}]];
        var partyMemcon = [[${user.proposer.partyMemcon}]];
        
        //进度条参数
        var progress;
        var type;
        if(partyMemcon == null){
        	if(partyApplication == null){
        		progress = "0%";
        	} else{
        		progress = "40%"
        	}
        }else{
        	progress = "100%";
        }
        $('#text').html(progress);
        
    </script>
    
    <script>
    
    function upload(value){
    	var path;//文件类型
    	switch(value){
    	case 1:
	    	path = 'partyApplication';
	    	break;
    	case 2:
	    	path = 'reportFirst';
	    	break;
	    case 3:
	    	path = 'reportSecond';
	    	break;
	    case 4:
	    	path = 'reportThird';
	    	break;
	    case 5:
	    	path = 'reportFourth';
	    	break;
	    case 6:
	    	path = 'memoir';
	    	break;
	    case 7:
	    	path = 'partyApplicaiton';
	    	break;
	    case 8:
	    	path = 'reportFifth';
	    	break;
	    case 9:
	    	path = 'reportSixth';
	    	break;
	    case 10:
	    	path = 'reportSeventh';
	    	break;
	    case 11:
	    	path = 'reportEighth';
	    	break;
	    case 12:
	    	path = 'officialApplication';
	    	break;		
    	};
		swal({
		  title: '提交文件',
		  input: 'file',
		    inputAttributes: {
    			accept: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/msword'
  			},
		  showCancelButton: true,
		  confirmButtonText: '确认提交',
		  showLoaderOnConfirm: true,
		  //提交前函数
		  preConfirm: function(file) {
		  	//校验函数
		    return new Promise(function(resolve, reject) { //返回resolve()为通过，reject()拒绝
		      //校验是否为doc或者docx
		        if (file.type === 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' || value.type === 'application/msword') {
		          resolve();
		        } else {
		            swal(
				    '文件格式不正确！',
				    '只能上传doc或docx类型的文件',
				    'warning'
				  ); 
		        }
		    });
		  },
		  allowOutsideClick: false
		}).then(	//接着执行
		   function (file) {
		   var fm = new FormData();
		   if(file.value == undefined){
		   		return;
		   }
		   fm.append("file", file.value);
		   fm.append("userId", userId);
		   fm.append("type", path);
		   $.ajax({
		   		url: '/module/proposer/materials/upload',
		   		type: 'post',
		   		data: fm,
		   		dataType: 'json',
		   		contentType: false, //禁止设置请求类型
           		processData: false, //禁止jquery对DAta数据的处理,默认会处理
            	//禁止的原因是,FormData已经帮我们做了处理
		   		success: function(result){
		   			if(result.code === 0){
		   				swal(
						  '一切顺利',
						  result.msg,
						  'success'
						).then(function(){
							//刷新页面
							window.location.reload();
						});
						
		   			} else{
		   				swal(
						  '抱歉',
						  result.msg,
						  'error'
						)
		   			}
		   		},
		   		error: function(result){
		   				swal(
						  '抱歉',
						  '请求失败，请于网站管理员联系',
						  'error'
						)
		   		}
		   });
		}
		);
    }
    </script>
    
    <script th:inline="javascript">
    	//判断用户是否补全信息，否则跳转信息修改页面
    	var info_state = [[${user.info_state}]];
    	var roleIds = [[${user.roleIds}]];
    	if(info_state == 0){
	    	switch(roleIds[0]){
	    		case 2:
	    			swal({
					  title: '请补全信息后进行操作',
					  text: '',
					  type: 'warning',
					  confirmButtonText: '前往补全',
					}).then(function(isConfirm) {
						window.location.href = "/system/user/profile/edit/" + [[${user.userId}]];
					}); 
	    			break;
	    	}
    	}
    	
    </script>

</body>
</html>
